package win.smartown.android.utils

import android.support.design.widget.Snackbar
import android.util.TypedValue
import android.view.View
import android.widget.TextView
import win.smartown.android.R

/**
 * Created by smartown on 2017/6/13 16:26.
 * Description:
 */
object SnackbarUtil {

    fun newSnackbar(rootView: View): Snackbar {
        val snackbar = Snackbar.make(rootView, "", 0)
        val resources = rootView.resources
        snackbar.view.setBackgroundColor(resources.getColor(R.color.snack_bar_back))

        val textView = snackbar.view.findViewById(android.support.design.R.id.snackbar_text) as TextView
        textView.setTextColor(resources.getColor(R.color.snack_bar_text_color))
        textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, resources.getDimensionPixelSize(R.dimen.snack_bar_text_size).toFloat())

        val actionTextView = snackbar.view.findViewById(android.support.design.R.id.snackbar_action) as TextView
        actionTextView.setTextColor(resources.getColor(R.color.snack_bar_action_color))
        actionTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, resources.getDimensionPixelSize(R.dimen.snack_bar_action_size).toFloat())
        return snackbar
    }

}
